<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta content="en" name="language">
	<title>Magick::Geometry</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link media="screen" href="../docutils-articles.css" type="text/css" rel="stylesheet">

</head>

<body>

<div class="banner">
<img src="../images/gm-107x76.png" alt="GraphicMagick logo" width="107" height="76" />
<span class="title">GraphicsMagick</span>
<form action="http://www.google.com/search">
  <input type="hidden" name="domains" value="www.graphicsmagick.org" />
  <input type="hidden" name="sitesearch" value="www.graphicsmagick.org" />
<span class="nowrap"><input type="text" name="q" size="25" maxlength="255" />&nbsp;<input type="submit" name="sa" value="Search" /></span>
</form>
</div>


<div class="navmenu">
<ul>
  <li><a href="../index.html">Home</a></li>
  <li><a href="../project.html">Project</a></li>
  <li><a href="../download.html">Download</a></li>
  <li><a href="../README.html">Install</a></li>
  <li><a href="../Hg.html">Source</a></li>
  <li><a href="../NEWS.html">News</a> </li>
  <li><a href="../utilities.html">Utilities</a></li>
  <li><a href="../programming.html">Programming</a></li>
  <li><a href="../reference.html">Reference</a></li>
</ul>
</div>

<main id="magick-geometry">
<h1 class="title">Magick::Geometry</h1>
<!-- -*- mode: rst -*- -->
<!-- This text is in reStucturedText format, so it may look a bit odd. -->
<!-- See http://docutils.sourceforge.net/rst.html for details. -->
<p>Geometry provides a convenient means to specify a geometry
argument. The object may be initialized from a C string or C++ string
containing a geometry specification. It may also be initialized by
more efficient parameterized constructors.</p>
<section id="x11-geometry-specifications">
<h1>X11 Geometry Specifications</h1>
<p>X11 geometry specifications are in the form
&quot;&lt;width&gt;x&lt;height&gt;{+-}&lt;xoffset&gt;{+-}&lt;yoffset&gt;&quot; (where width, height,
xoffset, and yoffset are numbers) for specifying the size and
placement location for an object.</p>
<p>The width and height parts of the geometry specification are measured
in pixels. The xoffset and yoffset parts are also measured in pixels
and are used to specify the distance of the placement coordinate from
the left and top and edges of the image, respectively. Both types of
offsets are measured from the indicated edge of the object to the
corresponding edge of the image. The X offset may be specified in the
following ways:</p>
<table>
<colgroup>
<col style="width: 13%" />
<col style="width: 87%" />
</colgroup>
<tbody>
<tr><td><p>+xoffset</p></td>
<td><p>The left edge of the object is to be placed xoffset
pixels in from the left edge of the image.</p></td>
</tr>
<tr><td><p>-xoffset</p></td>
<td><p>The left edge of the object is to be placed outside the
image, xoffset pixels out from the left edge of the image.</p></td>
</tr>
</tbody>
</table>
<p>The Y offset has similar meanings:</p>
<table>
<colgroup>
<col style="width: 14%" />
<col style="width: 86%" />
</colgroup>
<tbody>
<tr><td><p>+yoffset</p></td>
<td><p>The top edge of the object is to be yoffset pixels below
the top edge of the image.</p></td>
</tr>
<tr><td><p>-yoffset</p></td>
<td><p>The top edge of the object is to be yoffset pixels above
the top edge of the image.</p></td>
</tr>
</tbody>
</table>
<p>Offsets must be given as pairs; in other words, in order to specify
either xoffset or yoffset both must be present.</p>
</section>
<section id="graphicsmagick-extensions-to-x11-geometry-specifications">
<h1>GraphicsMagick Extensions To X11 Geometry Specifications</h1>
<p>GraphicsMagick has added a number of qualifiers to the standard
geometry string for use when resizing images. The form of an extended
geometry string is
&quot;&lt;width&gt;x&lt;height&gt;{+-}&lt;xoffset&gt;{+-}&lt;yoffset&gt;{%}{&#64;}{!}{^}{&lt;}{&gt;}&quot;. Extended
geometry strings should only be used when resizing an image. Using an
extended geometry string for other applications may cause the API call
to fail. The available qualifiers are shown in the following table:</p>
<table>
<caption>GraphicsMagick Geometry Qualifiers</caption>
<colgroup>
<col style="width: 12%" />
<col style="width: 88%" />
</colgroup>
<thead>
<tr><th class="head"><p>Qualifier</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr><td><p>%</p></td>
<td><p>Interpret width and height as a percentage of the current size.</p></td>
</tr>
<tr><td><p>!</p></td>
<td><p>Resize to width and height exactly, loosing original aspect ratio.</p></td>
</tr>
<tr><td><p>&lt;</p></td>
<td><p>Resize only if the image is smaller than the geometry specification.</p></td>
</tr>
<tr><td><p>&gt;</p></td>
<td><p>Resize only if the image is greater than the geometry specification.</p></td>
</tr>
<tr><td><p>&#64;</p></td>
<td><p>Resize such that width and height are a maximum area in total pixels.</p></td>
</tr>
<tr><td><p>^</p></td>
<td><p>Dimensions are treated as minimum rather than maximum values.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="postscript-page-size-extension-to-geometry-specifications">
<h1>Postscript Page Size Extension To Geometry Specifications</h1>
<p>Any geometry string specification supplied to the Geometry constructor
is considered to be a Postscript page size nickname if the first
character is not numeric. The page size nickname is not case
sensitive. The Geometry constructor converts these page size
specifications into the equivalent numeric geometry string
specification (preserving any offset component) prior to conversion to
the internal object format. Postscript page size specifications are
short-hand for the pixel geometry required to fill a page of that
size. Since the 11x17 inch page size used in the US starts with a
digit, it is not supported as a Postscript page size
nickname. Instead, substitute the geometry specification &quot;792x1224&gt;&quot;
when 11x17 output is desired.</p>
<table>
<caption>Postscript Page Size Nicknames</caption>
<colgroup>
<col style="width: 32%" />
<col style="width: 68%" />
</colgroup>
<thead>
<tr><th class="head"><p>Postscript Nickname</p></th>
<th class="head"><p>Equivalent Extended Geometry Specification</p></th>
</tr>
</thead>
<tbody>
<tr><td><p>A0</p></td>
<td><p>2384x3370&gt;</p></td>
</tr>
<tr><td><p>A1</p></td>
<td><p>1684x2384&gt;</p></td>
</tr>
<tr><td><p>A10</p></td>
<td><p>73x105&gt;</p></td>
</tr>
<tr><td><p>A2</p></td>
<td><p>1191x1684&gt;</p></td>
</tr>
<tr><td><p>A3</p></td>
<td><p>842x1191&gt;</p></td>
</tr>
<tr><td><p>A4</p></td>
<td><p>595x842&gt;</p></td>
</tr>
<tr><td><p>A4SMALL</p></td>
<td><p>595x842&gt;</p></td>
</tr>
<tr><td><p>A5</p></td>
<td><p>420x595&gt;</p></td>
</tr>
<tr><td><p>A6</p></td>
<td><p>297x420&gt;</p></td>
</tr>
<tr><td><p>A7</p></td>
<td><p>210x297&gt;</p></td>
</tr>
<tr><td><p>A8</p></td>
<td><p>148x210&gt;</p></td>
</tr>
<tr><td><p>A9</p></td>
<td><p>105x148&gt;</p></td>
</tr>
<tr><td><p>ARCHA</p></td>
<td><p>648x864&gt;</p></td>
</tr>
<tr><td><p>ARCHB</p></td>
<td><p>864x1296&gt;</p></td>
</tr>
<tr><td><p>ARCHC</p></td>
<td><p>1296x1728&gt;</p></td>
</tr>
<tr><td><p>ARCHD</p></td>
<td><p>1728x2592&gt;</p></td>
</tr>
<tr><td><p>ARCHE</p></td>
<td><p>2592x3456&gt;</p></td>
</tr>
<tr><td><p>B0</p></td>
<td><p>2920x4127&gt;</p></td>
</tr>
<tr><td><p>B1</p></td>
<td><p>2064x2920&gt;</p></td>
</tr>
<tr><td><p>B10</p></td>
<td><p>91x127&gt;</p></td>
</tr>
<tr><td><p>B2</p></td>
<td><p>1460x2064&gt;</p></td>
</tr>
<tr><td><p>B3</p></td>
<td><p>1032x1460&gt;</p></td>
</tr>
<tr><td><p>B4</p></td>
<td><p>729x1032&gt;</p></td>
</tr>
<tr><td><p>B5</p></td>
<td><p>516x729&gt;</p></td>
</tr>
<tr><td><p>B6</p></td>
<td><p>363x516&gt;</p></td>
</tr>
<tr><td><p>B7</p></td>
<td><p>258x363&gt;</p></td>
</tr>
<tr><td><p>B8</p></td>
<td><p>181x258&gt;</p></td>
</tr>
<tr><td><p>B9</p></td>
<td><p>127x181&gt;</p></td>
</tr>
<tr><td><p>C0</p></td>
<td><p>2599x3676&gt;</p></td>
</tr>
<tr><td><p>C1</p></td>
<td><p>1837x2599&gt;</p></td>
</tr>
<tr><td><p>C2</p></td>
<td><p>1298x1837&gt;</p></td>
</tr>
<tr><td><p>C3</p></td>
<td><p>918x1296&gt;</p></td>
</tr>
<tr><td><p>C4</p></td>
<td><p>649x918&gt;</p></td>
</tr>
<tr><td><p>C5</p></td>
<td><p>459x649&gt;</p></td>
</tr>
<tr><td><p>C6</p></td>
<td><p>323x459&gt;</p></td>
</tr>
<tr><td><p>C7</p></td>
<td><p>230x323&gt;</p></td>
</tr>
<tr><td><p>EXECUTIVE</p></td>
<td><p>540x720&gt;</p></td>
</tr>
<tr><td><p>FLSA</p></td>
<td><p>612x936&gt;</p></td>
</tr>
<tr><td><p>FLSE</p></td>
<td><p>612x936&gt;</p></td>
</tr>
<tr><td><p>FOLIO</p></td>
<td><p>612x936&gt;</p></td>
</tr>
<tr><td><p>HALFLETTER</p></td>
<td><p>396x612&gt;</p></td>
</tr>
<tr><td><p>ISOB0</p></td>
<td><p>2835x4008&gt;</p></td>
</tr>
<tr><td><p>ISOB1</p></td>
<td><p>2004x2835&gt;</p></td>
</tr>
<tr><td><p>ISOB10</p></td>
<td><p>88x125&gt;</p></td>
</tr>
<tr><td><p>ISOB2</p></td>
<td><p>1417x2004&gt;</p></td>
</tr>
<tr><td><p>ISOB3</p></td>
<td><p>1001x1417&gt;</p></td>
</tr>
<tr><td><p>ISOB4</p></td>
<td><p>709x1001&gt;</p></td>
</tr>
<tr><td><p>ISOB5</p></td>
<td><p>499x709&gt;</p></td>
</tr>
<tr><td><p>ISOB6</p></td>
<td><p>354x499&gt;</p></td>
</tr>
<tr><td><p>ISOB7</p></td>
<td><p>249x354&gt;</p></td>
</tr>
<tr><td><p>ISOB8</p></td>
<td><p>176x249&gt;</p></td>
</tr>
<tr><td><p>ISOB9</p></td>
<td><p>125x176&gt;</p></td>
</tr>
<tr><td><p>LEDGER</p></td>
<td><p>1224x792&gt;</p></td>
</tr>
<tr><td><p>LEGAL</p></td>
<td><p>612x1008&gt;</p></td>
</tr>
<tr><td><p>LETTER</p></td>
<td><p>612x792&gt;</p></td>
</tr>
<tr><td><p>LETTERSMALL</p></td>
<td><p>612x792&gt;</p></td>
</tr>
<tr><td><p>QUARTO</p></td>
<td><p>610x780&gt;</p></td>
</tr>
<tr><td><p>STATEMENT</p></td>
<td><p>396x612&gt;</p></td>
</tr>
<tr><td><p>TABLOID</p></td>
<td><p>792x1224&gt;</p></td>
</tr>
</tbody>
</table>
<p>The following is the definition of the Magick::Geometry class:</p>
<pre class="literal-block">class Geometry
{
public:

  Geometry ( unsigned int width_,
             unsigned int height_,
             unsigned int xOff_ = 0,
             unsigned int yOff_ = 0,
             bool xNegative_ = false,
             bool yNegative_ = false );
  Geometry ( const std::string &amp;geometry_ );
  Geometry ( const char * geometry_ );
  Geometry ( const Geometry &amp;geometry_ );
  Geometry ( );
  ~Geometry ( void );

  // Width
  void          width ( unsigned int width_ );
  unsigned int  width ( void ) const;

  // Height
  void          height ( unsigned int height_ );
  unsigned int  height ( void ) const;

  // X offset from origin
  void          xOff ( unsigned int xOff_ );
  unsigned int  xOff ( void ) const;

  // Y offset from origin
  void          yOff ( unsigned int yOff_ );
  unsigned int  yOff ( void ) const;

  // Sign of X offset negative? (X origin at right)
  void          xNegative ( bool xNegative_ );
  bool          xNegative ( void ) const;

  // Sign of Y offset negative? (Y origin at bottom)
  void          yNegative ( bool yNegative_ );
  bool          yNegative ( void ) const;

  // Width and height are expressed as percentages
  void          percent ( bool percent_ );
  bool          percent ( void ) const;

  // Resize without preserving aspect ratio (!)
  void          aspect ( bool aspect_ );
  bool          aspect ( void ) const;

  // Resize if image is greater than size (&gt;)
  void          greater ( bool greater_ );
  bool          greater ( void ) const;

  // Resize if image is less than size (&lt;)
  void          less ( bool less_ );
  bool          less ( void ) const;

  // Resize image to fit total pixel area specified by dimensions (&#64;).
  void          limitPixels ( bool limitPixels_ );
  bool          limitPixels ( void ) const;

  // Dimensions are treated as minimum rather than maximum values (^)
  void          fillArea ( bool fillArea_ );
  bool          fillArea ( void ) const;

  // Does object contain valid geometry?
  void          isValid ( bool isValid_ );
  bool          isValid ( void ) const;

  // Set via geometry string
  const Geometry&amp; operator = ( const std::string &amp;geometry_ );
  const Geometry&amp; operator = ( const char * geometry_ );

  // Assignment operator
  Geometry&amp; operator= ( const Geometry&amp; Geometry_ );

  // Return geometry string
  operator std::string() const;

};</pre>
<p>Copyright © Bob Friesenhahn 1999 - 2022</p>
</section>
</main>


<hr class="docutils">
<div class="document">
    <p><a href="../Copyright.html">Copyright</a> © GraphicsMagick Group 2002-2025<!--SPONSOR_LOGO--></p>
</div>

</main>
</body>
</html>
